<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<div class="span12">
    <div class="well grey span11">
        <div class="well-header">
            <h5>添加公司</h5>
        </div>

        <div class="well-content no-search">
        <form id="company">
            <div class="form_row">
                <label class="field_name align_right">公司名：</label>
                <div class="field">
                    <input name="name" class="span4" type="text">
                </div>
            </div>
            
            <div class="form_row">
                <label class="field_name align_right">地址：</label>
                <div class="field">
                    <input name="address" class="span2" type="text">
                </div>
            </div>
            
            <div class="form_row">
                <label class="field_name align_right">邮箱：</label>
                <div class="field">
                    <input name="email" class="span4" type="text">
                </div>
            </div>
            
            <div class="form_row">
                <div class="field">
                    <a id="saveCompany" href="javascript:void(0);" class="btn red submit">提交</a>
                    <a href="javascript:Fitz.listPage('company/list');" class="btn light_blue">取消</a>
                </div>
            </div>
            </form>
        </div>
    </div>
</div>

<script>
jQuery(function($){
	
    $('#saveCompany').click(function(){
    	Company.validateCompany(function(){//validate 做基本的验证
		   //这里做业务验证
		   /* var age = $("input[name='age']").val();
		   if (Number(age) < 1) {
			   alert("age must > 0");
			   return;
		   } */
			$.ajax({
				url: appCtx + "/web/company/create",
				type: 'post',
				data:$("form").serialize(),
				dataType: "json",
				success: function(json) {
					if (json.code == "0") {
						Fitz.alert("用户创建成功!", function(){
							Fitz.listPage("company/list");
						});
					} else {
						Fitz.alert(json.message);
					}
				},
				error: function(xhr, textStatus, errorThrown){
					alert(errorThrown);
				}
			});
		});
    });
    
    $('#cancel').click(function(){
    	Fitz.listPage("company/list");
    });
	
});
</script>
